package com.yzs.base.utils

import android.util.Log

/**
 * author : yzs
 * time   : 2021/06/28
 * desc   : Log
 */
object LUtils {
    var TAG = "TAG_Log"
    var TAG_HTTP = "TAG_Http"

    const val RELEASE = 10

    const val VERBOSE = 1
    const val DEBUG = 2
    const val INFO = 3
    const val WARN = 4
    const val ERROR = 5

    private var LEVEL = RELEASE

    /**
     * 控制只在开发模式下才打印
     */
    fun init(level: Int) {
        LEVEL = level
    }

    fun setLogTag(tag: String) {
        TAG = tag
    }

    fun setLogHttpTag(tag: String) {
        TAG_HTTP = tag
    }

    fun http(message: String?) {
        if (LEVEL <= DEBUG) Log.d(TAG_HTTP, message ?: "message == null")
    }

    fun d(message: String?) {
        if (LEVEL <= DEBUG) Log.d(TAG, message ?: " message == null")
    }

    fun w(message: String?) {
        if (LEVEL <= WARN) Log.w(TAG, message ?: " message == null")
    }

    fun e(message: String?) {
        if (LEVEL <= ERROR) Log.e(TAG, message ?: " message == null")
    }
}